#include "../Header/Precompiled.h"
#include "../Header/MessageHandler.h"

	MessageHandler* gMsgHandler;

	MessageHandler::MessageHandler(std::vector<System*>* systems) : Systems(systems)
	{
		gMsgHandler = this;
	}

	// Messages received from other systems or objects -- can be sent immediately or delayed
	void MessageHandler::ReceiveMessage(Message* msg)
	{
		//ErrorIf(msg->GetType() >= MT_MAX, "ERROR: Failed to broadcast message. Invalid message type!");

		for(SysIt it = Systems->begin(); it != Systems->end(); ++it)
		{
			(*it)->ReceiveMessage(msg);
		}
	}

	MessageHandler::~MessageHandler()
	{
		gMsgHandler = NULL;
	}